package com.shiro.demo.project.system.login.domain;

import lombok.Data;
import lombok.NonNull;

import java.util.Collection;

@Data
public class Role {
    private String username;
    private String roleName;
    private Collection<Permission> permissions;

    public Role(){ }
    public Role(String username, String roleName, Collection<Permission> permissions){
        this(roleName, permissions);
        this.username = username;
    }
    public Role(String roleName, @NonNull Collection<Permission> permissions) {
        this.roleName = roleName;
        this.permissions = permissions;
        permissions.forEach(permission -> {
            permission.setRoleName(roleName);
        });
    }
    public Role(String username, String roleName){
        this.username = username;
        this.roleName = roleName;
    }
}
